]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
weather: Disentangle _useAutoLocation from Weather setting
authorFlorian Müllner <fmuellner@gnome.org>
Sun, 19 Mar 2017 15:34:53 +0000 (16:34 +0100)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 20 Mar 2017 18:02:08 +0000 (19:02 +0100)
We currently use automatic location for weather forecasts if the
corresponding Weather setting is set, however we should take other
factors into account as well:

 - whether location services are enabled at all
 - whether Weather has been authorized to use them

In preparation of these changes, track the setting's value in a
separate property and make _useAutoLocation a getter, so we can
extend it with additional conditions easily.

https://bugzilla.gnome.org/show_bug.cgi?id=780252

js/misc/weather.js

index 775d053011dd210ae473a01c5518b6b2650ca039..04e3295dc928ea39f67caeede6a52b6405944ecf 100644 (file)
@@ -20,7 +20,7 @@ const WeatherClient = new Lang.Class({
         this._locationValid = false;
         this._lastUpdate = GLib.DateTime.new_from_unix_local(0);
 
-        this._useAutoLocation = false;
+        this._autoLocationRequested = false;
         this._mostRecentLocation = null;
 
         this._gclueService = null;
@@ -81,6 +81,10 @@ const WeatherClient = new Lang.Class({
             this._loadInfo();
     },
 
+    get _useAutoLocation() {
+        return this._autoLocationRequested;
+    },
+
     _loadInfo: function() {
         let id = this._weatherInfo.connect('updated', () => {
             this._weatherInfo.disconnect(id);
@@ -165,10 +169,10 @@ const WeatherClient = new Lang.Class({
 
     _onAutomaticLocationChanged: function(settings, key) {
         let useAutoLocation = settings.get_boolean(key);
-        if (this._useAutoLocation == useAutoLocation)
+        if (this._autoLocationRequested == useAutoLocation)
             return;
 
-        this._useAutoLocation = useAutoLocation;
+        this._autoLocationRequested = useAutoLocation;
 
         this._updateLocationMonitoring();